package pers.baiban.sqltoword.handler.impl;

import pers.baiban.sqltoword.handler.AbstractTableProcessor;
import pers.baiban.sqltoword.handler.TableProcessor;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBorder;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * 表格横条边框处理器
 *
 * @author 强子初
 * @since 2023/11/29
 */
@Component
@Order(5)
public class TableBorderInsideVProcessor extends AbstractTableProcessor implements TableProcessor {

    @Override
    public void doHandler() {
        if (needUpdate(param.getTableBorderInsideV())) {
            getInsideV().setVal(param.getTableBorderInsideV());
        }

        if(needUpdate(param.getTableBorderInsideVWidth())) {
            getInsideV().setSz(param.getTableBorderInsideVWidth());
        }
    }

    /**
     * 获取表格横条边框
     */
    private CTBorder getInsideV() {
        return borders.isSetInsideV() ? borders.getInsideV() : borders.addNewInsideV();
    }
}